package com.code4j.ai.mcp.client.sseMcp;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sse")
public class AiSeeController {

    ChatClient chatClient;

    public AiSeeController(
                        ChatClient.Builder chatClientBuilder,
                        ToolCallbackProvider toolCallbackProvider) {
        chatClient=chatClientBuilder
                .defaultToolCallbacks(toolCallbackProvider)
//                .defaultSystem("""
//                        你当前的username是{user_name}
//                        """)
                .build();
    }

    @RequestMapping("/chat")
    public String chat(@RequestParam(defaultValue = "查询分数") String message) {
        return chatClient.prompt()
                .user(message)
                .advisors(new SimpleLoggerAdvisor())
                .call().content();
    }


    @RequestMapping("/login")
    public String login(@RequestParam(defaultValue = "xushu")String username) throws InterruptedException {


        return "success!";
    }
}
